<?php
@session_start();
$PurviewLevel=2;
$CheckChannelID=0;  
$PurviewLevel_Others="user_vpp_group";

require("../../inc/common.inc.php");
require_once("../Admin_ChkPurview.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<TITLE>铭讯EOS网站后台管理</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<Meta name="Keywords" Content="济南网站建设 济南网站制作 山东网站建设 济南铭讯软件有限公司">
<Meta name="Description" Content="济南网站制作：铭讯软件专业服务优秀企业，致力于网站建、设网站推广、网络营销一体的全访位网络服务商">
<link rel="stylesheet" href="../images/style.css" type="text/css">
</head>
<body> 
<?php
if($actions=="del"){
//删除图片
	if(!$iddb&&!$id){
		$fun->popmassage("请选择要删除的信息","","popback");
		exit();
	}
	elseif(is_array($iddb))
	{
		foreach($iddb AS $key=>$value){
			$db->excu("delete from mx_user_group where id='$key' ");
		}
	}elseif($id){
		$db->excu("delete from mx_user_group where id='$id' ");
	}
	$url=$fromurl?$fromurl:$FROMURL;
	jump2("操作成功",$url,1);
	exit();
}
elseif($actions=="saveadd")
{
	if(trim($groupname)==""){
		$fun->popmassage("分类名称不能为空","","popback");
		exit();
	}
	if($orderid!=""){
		$orderid=intval($orderid);
	}else{$orderid=666;}
	$files=array(
		"groupname"    =>$groupname,
		"orderid"      =>$orderid,
		"adddate"      =>date("Y-m-d H:i:s"),
		"addid"        =>$_SESSION['mxadmin']['userid'],
	);
	$db->exe_insert("mx_user_group ",$files);

	jump2("添加成功","vpp_group.php");
	exit();
}
elseif ($actions=="savemodi"){
	$id=intval($id);
	if($id==0){
		$fun->popmassage("请选择要修改的信息","","popback");
		exit();
	}
	if(trim($groupname)==""){
		$fun->popmassage("分类名称不能为空","","popback");
		exit();
	}
	if($orderid!=""){
		$orderid=intval($orderid);
	}else{$orderid=666;}
	$files=array(
		"groupname"    =>$groupname,
		"orderid"      =>$orderid,
		"modidate"     =>date("Y-m-d H:i:s"),
		"modiid"       =>$_SESSION['mxadmin']['userid'],
	);
	$db->exe_update("mx_user_group ",$files,"id='$id'");

    $url=url_code($url);
	jump2("操作成功","$url",2);
	exit();
}
elseif($actions=="list")
{
//更新选中信息排列顺序
	foreach( $listdb AS $key=>$value){
		$value=intval($value);
		$db->excu("UPDATE mx_user_group SET orderid='$value' where id='$key'");
	}
	jump2("操作成功","$FROMURL",1);
	exit();
}

require("../mx_head.php");?>
<div class="right">
<?php
if ($actions=="add"){?>
<div class="xm2">
<h1 class="fl">添加VPP分组</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="vpp_group.php?actions=saveadd" onSubmit="return  check();">
    <tr class="list"> 
      <td width='19%' align="center"><b>分组名称：</b></td>
      <td width="81%"> 
        <input class=mmcinb type='text' name='groupname' id="groupname" value='' size="40">      </td>
    </tr>
    <tr class="list"> 
      <td align="center"><b>分组排序：</b></td>
      <td><input class=mmcinb type='text' name='orderid' id="orderid" value='666' size='30' onpropertychange="replaceNotNumber(this)" oninput="replaceNotNumber(this)"></td>
    </tr>
    <tr class="list"> 
      <td></td>
      <td> 
        <input class="button" type='submit' name='Submit' value='提交数据'>      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}
elseif ($actions=="modi"){
//修改链接
  $query="SELECT * from mx_user_group where id='$id' limit 1";
  $result=$db->excu($query);
  if ($db->num_rows($result)<=0){
	$fun->popmassage("请选择要修改的等级","","popback");
	exit();
  }
  $rsdb=$db->fetch_array($result);
  if ($gotourl==""){$gotourl=url_encode($_SERVER['HTTP_REFERER']);}
?>
<div class="xm2">
<h1 class="fl">修改VPP分组</h1>
</div>
<div class="xm2_b">
<div class="height10"></div>
<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="vpp_group.php" onSubmit="return  check();">
    <tr class="list"> 
      <td width='20%' align="center"><b>等级名称：</b></td>
      <td width="81%"> 
        <input class=mmcinb type='text' name='groupname' id="name" value='<?php echo $rsdb[groupname]?>' size="40">      </td>
    </tr>
    <tr class="list"> 
      <td align="center"><b>等级排序：</b></td>
      <td><input class=mmcinb type='text' name='orderid' id="orderid" value='<?php echo $rsdb[orderid]?>' size='30' onpropertychange="replaceNotNumber(this)" oninput="replaceNotNumber(this)"></td>
    </tr>
    <tr class="list"> 
      <td></td>
      <td> 
        <input class="button" type='submit' name='Submit' value='提交数据'>
		<input type="hidden" name="id" value="<?php echo $rsdb[id] ?>">
		<input type="hidden" name="url" value="<?php echo $gotourl?>">
		<input type="hidden" name="actions" value="savemodi">
      </td>
    </tr>
  </form>
</table>
<div class="height10"></div>
</div>
<?php 
}

else{
  
  $str="";
  $s="yz=$yz&";
  if ($yz!=""){
    $str=" and yz='$yz' ";
  }

  if(empty($pageindex)){
      $pageindex=1;
  }
  $pagesize=20;

  $table=" mx_user_group ";
  $order=" ORDER BY orderid,id";
  $column=" * ";
  $biaoid="id";
  $c=$db->listcount($table,$str);

  $list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);

?>
<div class="gk">
			<div class="ti2 fl">VPP用户分组管理</div>
			<ul class="fr">
				<li><span class="c1"><?php $znum=$db->listcount("mx_user_group","");echo $znum;?></span><span>分组总数</span></li>
			</ul>
			<div class="clear"></div>
</div>
<div class="height15"></div>
<div class="xm2">
<h1 class="fl">分组管理</h1>
</div>
<div class="xm2_b" style="border-bottom:0px;">
<div class="t">
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td>
	<div class="an1"><a href="vpp_group.php">所有分组</a></div>
	<div class="an2"><a href="vpp_group.php?actions=add">添加分组</a></div>
	</td>
	</tr>
	</table>
</div>
</div>
<div class="xm2_b">
<div class="height10"></div>

<table width='100%' cellspacing='1' cellpadding='5' class="table_southidc">
  <form name="form1" method="post" action="vpp_group.php">
    <tr align="center"> 
      <th width="10%">ID </th>
      <th width="50%">名称</th>
      <th width="20%">排序</th>
      <th width="20%">操作</th>
    </tr>
<?php
  if (!is_array($list) or $c==0){
  echo "<tr class=\"list1\"><td colspan=4 height=30><center>暂无信息</center></td></tr>";
  }
  else{
  for($i=0;$i<count($list);$i++){
?>
    <tr class="list"> 
      <td align="center"><input type="checkbox" name="iddb[<?php echo $list[$i][id]?>]" value="<?php echo $list[$i][id]?>" class="input_check"></td>
      <td><?php echo $list[$i][groupname]?></td>
      <td align="center"><input type="text" name="listdb[<?php echo $list[$i][id] ?>]" size="7" value="<?php echo $list[$i]['orderid']?>"></td>
      <td align="center"><a href="vpp_group.php?actions=modi&id=<?php echo $list[$i][id]?>">修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="vpp_group.php?actions=del&id=<?php echo $list[$i][id]?>" onClick="return confirm('确定要删除此信息吗?')">删除</a></td>
    </tr>
<?php
  }
  }
?>
  <input type="hidden" name="actions" value="">
  </form>
</table>
<?php if ($c>0){?>
			<div class="height10"></div>
			<div class="do_div">
				<div class="l"><a href="javascript:CheckAll(document.form1,'all')">全选</a>&nbsp;<a href="javascript:CheckAll(document.form1,'')">反选</a></div>
				<div class="l2">
				选择操作：
				<a href="javascript:if (confirm('删除后不可恢复,你确实要删除吗?')){ document.form1.actions.value='del';document.form1.submit();}">删除选中信息</a>
				<a href="javascript:document.form1.actions.value='list';document.form1.submit();">提交处理排序</a>
				</div>
			</div>
<?php }?>

<?php
	if ($c>$pagesize){
?>
			<div class="clear"></div>
			<div class="pagination">
			<?PHP
			echo $db->ThePage_mxsoft($s,$pageindex,$c,$pagesize)
			?>
			</div>
<?php
	}
?>
			<div class="clear"></div>
			<div class="height10"></div>
</div>
<script type="text/javascript" src="/mxsoft/js/jquerys-1.5.1.js"></script>
<script language="javascript">
$(document).ready(function(){  
	$(".table_southidc tr").mouseover(function(){   
	$(this).addClass("list2");}).mouseout(function(){   
	$(this).removeClass("list2");}) //移除该行的class   
	$(".table_southidc tr:even").addClass("list1");   
});   
</script> 

<?php
}
?>
<div class="clear"></div>
<div class="height10"></div>
</div>
<?php require("../mx_foot.php");?>
<script language="javascript">
function check(){
	if (!CheckLength("groupname","分组名称")){
		return false;
	}
	if (!CheckLength("orderid","分组排序")){
		return false;
	}
	if (!CheckNum("orderid","分组排序")){
		return false;
	}
}
</script>
</body>
</html>
